package com.homework;

import com.reflex.annotations.AutoRunMethod;

import java.lang.reflect.Method;

public class ReflexDemo11 {
    public static void main(String[] args) throws Exception {
        //获取Person类Class
        Class<?> aClass = Class.forName("com.reflex.Person");
        //获取sayHello方法
        Method declaredMethod = aClass.getDeclaredMethod("sayHello");
        //判断当前方法是否有AutoRunMethod注解
        if (declaredMethod.isAnnotationPresent(AutoRunMethod.class)){
            //获取注解
            AutoRunMethod annotation = declaredMethod.getAnnotation(AutoRunMethod.class);
            //获取注解的value属性的值
            int value = annotation.value();
            System.out.println("value = " + value);
        }
    }
}
